﻿using SendGridMail;
using SendGridMail.Transport;
using System.Net;
using System.Net.Mail;

public static class EmailService
{
    /// <summary>
    /// Send an email to the given address.
    /// </summary>
    /// <param name="To">Email address of the recipient</param>
    /// <param name="Subject">Email' subject</param>
    /// <param name="Body">Email body</param>
    public static void Send(string To, string Subject, string Body)
    {
        ISendGrid EmailToSend = SendGrid.GenerateInstance();
        EmailToSend.From = new MailAddress("ne-pas-repondre@lesmarrons.com", "Les marrons - AMAP");
        EmailToSend.AddTo(To);
        EmailToSend.Subject = Subject;
        EmailToSend.Html = "<html><body>" + Body + "</body></html>";
        REST.GetInstance(new NetworkCredential("Florent.Henry", "123456")).Deliver(EmailToSend);
        //REST.GetInstance(new NetworkCredential("your_sendgrid_username", "your_sendgrid_password")).Deliver(EmailToSend);
    }
}